package com.ccc.mq.multicenter.source;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author superC
 * @version 1.0.0
 * @date 2022/7/5
 */
@Component
public class UserProducer {

    /**
     * 中心MQ
     */
    @Resource(name = "centerMQTemplate")
    private RocketMQTemplate centerMQTemplate;

    /**
     * 站级MQ
     */
    @Resource(name = "stationMQTemplate")
    private RocketMQTemplate stationMQTemplate;


    @Value("${base.config.rocketmq.topic.testTopic}")
    private String testTopic;

    /**
     * 同步用户数据
     */
    public void syncUserData(String msg) {
        // 向中心同步
        this.centerMQTemplate.convertAndSend(testTopic, msg);

        // 向站级同步
//        this.stationMQTemplate.convertAndSend(testTopic, msg);
    }

}